//
//  TWFXRealTimeDataInfo.m
//  TWFXWeather
//
//  Created by Lion User on 13-10-5.
//  Copyright (c) 2013年 Lion User. All rights reserved.
//

#import "TWFXStruct_RealTimeWeatherInfo.h"

@implementation TWFXStruct_RealTimeWeatherInfo

-(id)init
{
    if (self = [super init]) {
        
    }
    
    return self;
}

-(void)dealloc
{
    self.WD = nil;
    self.WS = nil;
    self.SD = nil;
    self.WSE = nil;
    self.temp = nil;
    self.time = nil;
    
    [super dealloc];
}

//编码
-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.WD forKey:@"WD"];
    [aCoder encodeObject:self.WS forKey:@"WS"];
    [aCoder encodeObject:self.SD forKey:@"SD"];
    [aCoder encodeObject:self.WSE forKey:@"WSE"];
    [aCoder encodeObject:self.temp forKey:@"temp"];
    [aCoder encodeObject:self.time forKey:@"time"];
}

//解码
-(id)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super init]) {
        
        self.WD = [aDecoder decodeObjectForKey:@"WD"];
        self.WS = [aDecoder decodeObjectForKey:@"WS"];
        self.SD = [aDecoder decodeObjectForKey:@"SD"];
        self.WSE = [aDecoder decodeObjectForKey:@"WSE"];
        self.temp = [aDecoder decodeObjectForKey:@"temp"];
        self.time = [aDecoder decodeObjectForKey:@"time"];
    }
    
    return self;
}


+(void) RealTimeInfoWithDictionary:(NSDictionary *)dicData RealTimeData:(TWFXStruct_RealTimeWeatherInfo *)realTimeWeatherInfo Error:(NSError *)error
{
    NSDictionary *dicRealTime;
    if (dicData == nil)
    {
        return;
    }
    else
    {
        dicRealTime = dicData[@"weatherinfo"];
    }
    
    if (realTimeWeatherInfo == nil) {
        
        realTimeWeatherInfo = [[TWFXStruct_RealTimeWeatherInfo alloc] init];
    }
    
    error = nil;
    
    @try {
        
        realTimeWeatherInfo.WD = dicRealTime[@"WD"];
        realTimeWeatherInfo.SD = dicRealTime[@"SD"];
        realTimeWeatherInfo.WS = dicRealTime[@"WS"];
        realTimeWeatherInfo.temp = dicRealTime[@"temp"];
        realTimeWeatherInfo.time = dicRealTime[@"time"];
    }
    @catch (NSException *exception) {
        
        error = [NSError errorWithDomain:exception.name code:0 userInfo:[exception userInfo]];
    }
    @finally {
        
        
    }
    
    
}

@end
















